package com.haoshui.service.impl;

import com.haoshui.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ps")
public class PermissionService {

    @Autowired
    private SecurityUtils securityUtils;
    /**
     * 判断登录的用有没有权限
     * @param permisson
     * @return
     */
    public boolean hasPermission(String permisson){
        if(securityUtils.isAdmin()){
            return true;
        }
        List<String> permissons = SecurityUtils.getLoginUser().getPermissons();
        boolean contains = permissons.contains(permisson);
        if(permissons==null){
            return false;
        }else{
            return   permissons.contains(permisson);
        }

    }
}
